import { listColumns, columns, shipments } from './index.const';
import ElEditable from '@components/el-editable';
import { IndexService } from './index.service';
const indexService = new IndexService();
export default {
  components: {
    ElEditable
  },
  inject: ['apiMMallWeb'],
  data() {
    return {
      pickerOptions1: {
        disabledDate: time => {
          return time.getTime() < this.tableQuery.commitDateStart;
        }
      },
      tableQuery: {
        orderCode: '',
        orderStatus: '',
        commitDateEnd: '',
        commitDateStart: '',
        productLineCode: '',
        busModel: 1
      },
      tableData: {},
      columns: columns,
      shipments: shipments,
      listColumns: listColumns,
      fullscreen: false,
      dialogVisible: false,
      delDialogVisible: false,
      takeDialogVisible: false,
      shipmentsDetail: [],
      errorMsg: [],
      minDate: '',
      maxDate: '',
      payload: [],
      orderIds: []
    };
  },
  async created() {
    const data = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({ query: { busModel: 2 } });
    this.payload = data.content;
    indexService.getStatusName(this.payload);
  },
  mounted() {},
  methods: {
    // 重置
    queryFormReset() {
      this.$refs['queryForm'].resetFields();
    },
    // 查询
    async queryFormQuery() {
      const query = {
        busModel: 2,
        commitDateEnd: this.tableQuery.commitDateEnd,
        commitDateStart: this.tableQuery.commitDateStart,
        orderCode: this.tableQuery.orderCode,
        orderStatus: this.tableQuery.orderStatus,
        page: 0,
        pageSize: 20,
        productLineCode: this.tableQuery.productLineCode
      };
      const data = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({
        query: query
      });
      this.payload = data.content;
      indexService.getStatusName(data.content);
    },
    onSubmit() {},
    // 高亮
    heightLight({ row, rowIndex }) {
      if (row.orderStatus === 1) {
        return 'bgHeight';
      }
    },
    //校验失败
    async showDialog(scope) {
      this.dialogVisible = true;
      const data = await this.apiMMallWeb.PageListCheckFailMessageOrderV1ApiPOST({
        query: {
          orderId: scope.orderId,
          page: 0,
          pageSize: 20
        }
      });
      if (data.content) {
        this.errorMsg.push(data.content);
      }
    },
    //再次提交
    async resubmit(scope) {
      const data = await this.apiMMallWeb.OrderSubmitAgainOrderV1ApiPOST({
        mOrderQuery: {
          orderCode: scope.orderCode,
          orderId: scope.orderId,
          page: 0,
          pageSize: 0
        }
      });
      if (data === true) {
        alert('提交成功');
      }
    },
    // 删除弹窗
    delDialog(scope) {
      this.delDialogVisible = true;
      this.orderIds.push(scope.orderId);
    },
    // 确认删除
    async delSure() {
      const data = await this.apiMMallWeb.DeleteOrderOrderV1ApiPOST({ orderIds: this.orderIds });
      this.delDialogVisible = false;
      const res = await this.apiMMallWeb.OrderDetailListOrderV1ApiPOST({ query: {} });
      this.payload = res.content;
      indexService.getStatusName(this.payload);
    },
    // 取消删除
    concelDel() {
      this.delDialogVisible = false;
    },
    //收货
    takeDialog(scope) {
      this.shipmentsDetail.push(scope);
      this.takeDialogVisible = true;
    },
    //编辑
    async editGo(scope) {
      const data = await this.apiMMallWeb.OrderContractOrderV1ApiPOST({
        query: {
          orderId: scope.orderId,
          page: 0,
          pageSize: 20
        }
      });
      this.$router.push({
        path: '/other-order/report/add',
        query: {
          id: scope.orderId,
          detailid: scope.orderDetailId
        }
      });
    },
    //查看
    checkDetail(scope) {
      this.$router.push({
        path: '/other-order/report/detail',
        query: {
          id: scope.orderId
        }
      });
    }
  }
};
